package com.qtyx.nms

import android.app.Application
import android.content.Context
import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.FormatStrategy
import com.orhanobut.logger.Logger
import com.orhanobut.logger.PrettyFormatStrategy
import com.qtyx.nms.util.ConstantUtil
import com.qtyx.nms.util.FontUtils
import skin.support.SkinCompatManager
import skin.support.app.SkinAppCompatViewInflater
import skin.support.app.SkinCardViewInflater
import skin.support.constraint.app.SkinConstraintViewInflater
import skin.support.design.app.SkinMaterialViewInflater

class MyApp : Application() {
    companion object {
        private lateinit var mContext:MyApp
        fun getMyAppContext(): Context {
            return mContext
        }
    }
    override fun onCreate() {
        super.onCreate()
        mContext = this


        //打印日志
        val formatStrategy: FormatStrategy = PrettyFormatStrategy.newBuilder()
            .showThreadInfo(false)
            .methodCount(0)
            .tag("")
            .build()
        Logger.addLogAdapter(AndroidLogAdapter(formatStrategy))


//        CrashReport.initCrashReport(applicationContext, "b3a50da618", false)


        // 字体放在 assets 文件夹下
        FontUtils.getInstance().replaceSystemDefaultFontFromAsset(this, ConstantUtil.fontPathZhengYuan)


        //皮肤管理
        SkinCompatManager.withoutActivity(this)
            .addInflater(SkinAppCompatViewInflater()) // 基础控件换肤初始化
            .addInflater(SkinMaterialViewInflater()) // material design 控件换肤初始化[可选]
            .addInflater(SkinConstraintViewInflater()) // ConstraintLayout 控件换肤初始化[可选]
            .addInflater(SkinCardViewInflater()) // CardView v7 控件换肤初始化[可选]
            .setSkinWindowBackgroundEnable(false) // 关闭windowBackground换肤，默认打开[可选]
            .loadSkin()
    }

}